package com.nbjtjc.safe.api.cost;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.nbjtjc.safe.annotation.SysLog;
import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.mapper.cost.CostBudgetMonthMapper;
import com.nbjtjc.safe.model.cost.CostBudgetItem;
import com.nbjtjc.safe.model.cost.CostBudgetMonth;
import com.nbjtjc.safe.model.cost.CostBudgetSubItem;
import com.nbjtjc.safe.service.cost.CostBudgetSubItemService;

@RestController
@CrossOrigin("*")
@RequestMapping("/costBudgetSubItem")
public class CostBudgetSubItemController {
	@Autowired
	private  CostBudgetSubItemService costBudgetSubItemService;

	
	  @RequestMapping(value = "/delete",method = {RequestMethod.POST})
	  @SysLog("删除安全投入预算计划子项目")
	    public Result delete(@RequestBody CostBudgetSubItem costBudgetSubItem) {
	        Result result=new Result();
	        try {

	            result=costBudgetSubItemService.delete(costBudgetSubItem);

	        } catch (Exception e) {
	            e.printStackTrace();
	            result.setFalse(e.getMessage());
	        }
	        return result;
	    }
	  
	  @RequestMapping(value = "/deleteMultiple",method = {RequestMethod.POST})
	  @SysLog("批量删除安全投入预算计划子项目")
	    public Result deleteMultiple(@RequestBody CostBudgetItem costBudgetItem) {
	        Result result=new Result();
	        try {

	            result=costBudgetSubItemService.deleteMultiple(costBudgetItem.getCostBudgetSubItems());

	        } catch (Exception e) {
	            e.printStackTrace();
	            result.setFalse(e.getMessage());
	        }
	        return result;
	    }
	  
	  @RequestMapping(value = "/addOrUpdate",method = {RequestMethod.POST})
	  @SysLog("添加或更新安全投入预算计划子项目")
	    public Result add(@RequestBody CostBudgetSubItem costBudgetSubItem) {
	        Result result=new Result();
	        try {
	            result=costBudgetSubItemService.add(costBudgetSubItem);
	        } catch (Exception e) {
	            e.printStackTrace();
	            result.setFalse(e.getMessage());
	        }
	        return result;
	    }
	  
	  @RequestMapping(value = "/findByItemId",method = {RequestMethod.POST})
	    public Result findByItemId(@RequestBody CostBudgetItem costBudgetItem) {
	        Result result=new Result();
		  try{
			  result=costBudgetSubItemService.findByItemId(costBudgetItem);
		  }catch (Exception e) {
	            e.printStackTrace();
	            result.setFalse(e.getMessage());
	        }
	        return result;
	  }

}
